//
//  LOLTabBarController.m
//  LOL_Little_Box
//
//  Created by dllo on 16/3/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LOLTabBarController.h"

@interface LOLTabBarController ()

@end

@implementation LOLTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//NSForegroundColorAttributeName字典的key是属性字符串的属性
- (NSMutableDictionary *)getTextAttributedNormal{
    NSMutableDictionary *temDic = [NSMutableDictionary dictionary];
    temDic[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    return temDic;
}

/**自改字体高亮时候的颜色 */
- (NSMutableDictionary *)getTextAttributedHighLight{
    NSMutableDictionary *temDic = [NSMutableDictionary dictionary];
    temDic[NSForegroundColorAttributeName] = [UIColor blueColor];
    return temDic;
}

- (void)addChildViewController:(UIViewController *)childController Img:(NSString *)imgName ImgSelected:(NSString *)imgSelected Title:(NSString *)title{
    UIImage *normalImg = [[UIImage imageNamed:imgName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *selectedImg = [[UIImage imageNamed:imgSelected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self addChildViewController:childController];
    //!!!!不能再忘记了
    //!至少要先创建一个tabBarItem才能使用它的属性而不是它是默认存在的
    childController.tabBarItem = [[UITabBarItem alloc]initWithTitle:title image:normalImg selectedImage:selectedImg];
    
    //!修改对title的默认渲染
    [childController.tabBarItem setTitleTextAttributes:[self getTextAttributedNormal] forState:UIControlStateNormal];
    [childController.tabBarItem setTitleTextAttributes:[self getTextAttributedHighLight] forState:UIControlStateHighlighted];
    
    childController.title = title;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
